<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background-color: pink;
            text-align: center;
            line-height: 100px;
            color: #fff;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div>
        节流
    </div>
    <script>
        let flag = true
        const div = document.querySelector('div')
        div.addEventListener('click',function(){
            // 判断点击后条件
            if(flag){
                console.log('按一次');
                div.style.backgroundColor = '#ccc'
                flag = false
                // 计时器
                setTimeout(()=>{
                    flag = true
                    div.style.backgroundColor = 'pink'
                },1000)
            }
        })
    </script>
</body>
</html>